#ifndef VSSHADERMAINFUNCTION_H
#define VSSHADERMAINFUNCTION_H
#include "VSShaderFunction.h"
#include "VSRenderState.h"
namespace VSEngine2
{	class VSLight;
	DECLARE_Ptr(VSLight);
	class VSGRAPHIC_API VSShaderMainFunction : public VSShaderFunction
	{
		//RTTI
		DECLARE_RTTI;
		DECLARE_INITIAL_NO_CLASS_FACTORY;
	public:
		enum
		{
			SM_PHONE,
			SM_OREN_NAYAR,
			SM_MAX
		};
		enum //Specular Type
		{
			ST_BlinnPhong,
			ST_Phong,
			ST_MAX
		};
		enum // OutPut String Type
		{
			OST_FINAL,
			OST_NORMAL,
			OST_MAX
		};
		VSShaderMainFunction(const VSUsedName & ShowName,VSMaterial * pMaterial);
		virtual ~VSShaderMainFunction() = 0;
		virtual bool GetFuntionString(VSString &OutString)const = 0;
		virtual bool GetNormalString(VSString &OutString)const;
		virtual inline unsigned int GetSMType()const = 0;
		inline void SetLight(VSArray<VSLightPtr> &LightArray)
		{
			m_LightArray = LightArray;
		}
		inline void SetSRGBWrite(unsigned char uiVESRGBWrite)
		{
			m_uiVESRGBWrite = uiVESRGBWrite;
		}
		inline unsigned char GetSRGBWrite()const
		{
			return m_uiVESRGBWrite;
		}
		inline void SetSpecularType(unsigned char uiSpecularType)
		{
			m_uiSpecularType = uiSpecularType;
		}
		inline unsigned char GetSpecularType()const
		{
			return m_uiSpecularType;
		}
		inline void SetPassId(unsigned char uiPassId)
		{
			m_uiPassId = uiPassId;
		}
		inline unsigned char GetPassId()const
		{
			return m_uiPassId;
		}
		inline bool HasNormal()const
		{
			if (m_pInput[IN_NORMAL]->GetOutputLink())
			{
				return true;
			}
			return false;
		}
		virtual bool GetShaderTreeString(VSString &OutString,unsigned int uiOutPutStringType);
		virtual bool GetInputValueString(VSString &OutString,unsigned int uiOutPutStringType)const;
		inline VSRenderState & GetRenderState()
		{
			return m_RenderState;
		}
		inline void SetBlendState(VSBlendState * pBlendState)
		{
			m_RenderState.SetBlendState(pBlendState);
		}
		inline void SetDepthStencilState(VSDepthStencilState *pDepthStencilState)
		{
			m_RenderState.SetDepthStencilState(pDepthStencilState);
		}
		inline void SetRasterizerState(VSRasterizerState *pRasterizerState)
		{
			m_RenderState.SetRasterizerState(pRasterizerState);
		}
		inline void AddClipPlane(const VSPlane3 & Plane)
		{
			m_RenderState.AddPlane(Plane);
		}
		inline void AddScissorRect(const VSRect2 & Rect)
		{
			m_RenderState.AddRect(Rect);
		}
	protected:
		VSShaderMainFunction();
		VSArray<VSLightPtr> m_LightArray;
		unsigned char m_uiVESRGBWrite;
		unsigned char m_uiSpecularType;
		unsigned char m_uiPassId;
		void GetDelareString(VSString &OutString);
		VSRenderState	m_RenderState;
	public:
		enum
		{
			OUT_COLOR,
			OUT_MAX
		
		};
	public:
		enum
		{
			IN_DIFFUSE_COLOR,
			IN_EMISSIVE_COLOR,
			IN_SPECULAR_COLOR,
			IN_SPECULAR_POW,
			IN_NORMAL,
			IN_ALPHA,
			IN_MAX
		};
	};
	DECLARE_Ptr(VSShaderMainFunction);
	VSTYPE_MARCO(VSShaderMainFunction);
}
#endif